<?php
/**
 * Created by PhpStorm.
 * User: HLG
 * Date: 2019/10/14
 * Time: 17:28
 */
namespace app\api\validate;
use think\Validate;

class User extends Validate
{
    /**
     * 验证规则
     * @var array
     */
    protected $rule = [

        // 用户手机号
        'mobile' => 'require|number|min:11|max:11',
        'pay_password' => 'require|min:6',
        'password' => 'require|min:6',
        'code' => 'require',
        'true_name' => 'require',
        'idcard' => 'require|min:18|max:18',
    ];

    /**
     * 定义错误信息
     * 格式：'字段名.规则名'    => '错误信息'
     *
     * @var array
     */
    protected $message = [
        'phone.require'      => '手机号不能为空',
        'phone.number'    => '手机号只能是数字',
        'phone.min'      => '手机号最少11位',
        'phone.max'      => '手机号最大11位',
        'pay_password.require'     => '资金密码不能为空',
        'pay_password.min'     => '资金密码最小长度：6个字符',
        'password.require'     => '密码不能为空',
        'password2.require'     => '密码不能为空',
        'password.min'          => '密码最小长度：6个字符',
        'password2.min'          => '密码最小长度：6个字符',
        'code.require'          => '验证码不能为空',
        'true_name.require' => '真实姓名不能为空',
        'idcard.require' => '身份证号码不能为空',
        'idcard.min' => '身份证最小18位',
        'idcard.max' => '身份证最大18位',
    ];
    /**
     * 使用场景
     */
    protected $scene = [
        'register' => ['phone','password','code','password2'],
        'login'  =>  ['phone','password'],//,'pay_password'
        'authentic' => ['mobile','true_name','idcard'],
    ];

}